(function(){
//JS 初始化页面大小 以高度为百分百。自适应宽度，按ip6比例锁定0.56
var dsn=$(window).height()/$(window).width();
//$('.arealayer').width($(window).height()*0.56);
$('.arealayer').width($(window).width());
$('.arealayer').height($(window).height()); 
 
//配置
var config = {
	'audio':{
		'icon':'audio-record-play',
		'text':true
	},
	'loading': 'loading-ic'
};

//loading
window.onload = function(){
	$('#loading').hide();
}

//END页面和分享框
$('.js-btn-share').bind('tap',function(){
	$('.share').show();
	$('.sharebg').show();
}) 
$('.js-btn-reload').bind('tap',function(){
	   window.location.reload();

}) 
//定义AJAZX按钮
$('.share,.sharebg').tap(function () {
	$(this).hide();
    
});
 


//开始页面切换流程
var pageIndex = 1,
	pageTotal = $('.page').length,
	towards = { up:1, right:2, down:3, left:4},
	isAnimating = false;

//禁用手机默认的触屏滚动行为
document.addEventListener('touchmove',function(event){
	event.preventDefault(); },false);

//页面从右向左走
$(document).swipeUp(function(){
	if (isAnimating) return;
	if (pageIndex < pageTotal) { 
		pageIndex+=1; 
	pageMove(towards.up);
	}else{
		//pageIndex=1;
	}; 
	
})

//页面从左向向走
$(document).swipeDown(function(){
	if (isAnimating) return;
	if (pageIndex > 1) { 
		pageIndex-=1; 
	pageMove(towards.down);	
	}else{
		//pageIndex=pageTotal;
	};
})

//页面切换主流程
function pageMove(tw){
	var lastPage;
	if(tw=='1'){
		if(pageIndex==1){
			lastPage = ".page-"+pageTotal;
		}else{
			lastPage = ".page-"+(pageIndex-1);
		}
		
	}else if(tw=='3'){
		if(pageIndex==pageTotal){
			lastPage = ".page-1";
		}else{
			lastPage = ".page-"+(pageIndex+1);
		}
		
	}

	var nowPage = ".page-"+pageIndex;
	
	$(nowPage).removeClass("hide");
	switch(tw) {
		case towards.up:
			outClass = '';//outClass = 'pt-page-moveToTop';
			inClass = '';//inClass = 'pt-page-moveFromBottom';
					
			
			$(lastPage+" .pagearrow2").addClass('pt-page-scalebig');
			$(nowPage+" .pagearrow2").removeClass('pt-page-scalebig');
			
			$(lastPage+" .z3").addClass('pt-page-zhedieup');
			$(nowPage+" .z3").removeClass('pt-page-zhedieup');
			
 	if(pageIndex==2 || pageIndex==12 ){
			$(lastPage).addClass( 'pt-page-moveToTop');
			$(nowPage).addClass(inClass);
		}else{
			setTimeout(function(){
			$(lastPage).addClass(outClass);
			$(nowPage).addClass(inClass);
			},600);
		}
	
	
	
			break;
		case towards.down:
			//outClass = '';
			outClass = 'pt-page-moveToBottom';
			//inClass = '';
			inClass = 'pt-page-moveFromTop';
			//$(lastPage+" .z3").addClass('pt-page-zhediedown');
			$(nowPage+" .z3").removeClass('pt-page-zhedieup');
			 
			$(lastPage).addClass(outClass);
			$(nowPage).addClass(inClass); 
			break;
	}
	isAnimating = true;
	/*
	$(lastPage).addClass(outClass);
	$(nowPage).addClass(inClass);
	*/
	
	
	/*
		$('.maptip').removeClass('animation-maptip');
		$('.js').removeClass('animation-js');
	*/
	console.log( pageIndex);

	
	
	setTimeout(function(){
		$(lastPage).removeClass('pt-page-zhedieup');
		$(lastPage).removeClass('pt-page-moveToTop');
		$(lastPage).removeClass('page-current');
		$(lastPage).removeClass(outClass);
		$(lastPage).addClass("hide");
		//$(lastPage).find("img").addClass("hide");
		
		$(nowPage).addClass('page-current');
		$(nowPage).removeClass(inClass);
		//$(nowPage).find("img").removeClass("hide");
		
		$(nowPage+' .maptip.t1').addClass('animation-maptip');
		$(nowPage+' .js.js1').addClass('animation-js');
		$(nowPage+' .a-taps .c1').addClass('animation-scale');
		
		isAnimating = false;
	},1200);
	/*
	setTimeout(function(){
		$(nowPage+' .maptip.t2').addClass('animation-maptip');
		$(nowPage+' .js.js2').addClass('animation-js');
		$(nowPage+' .a-taps .c2').addClass('animation-scale');
	},800);
	setTimeout(function(){
		$(nowPage+' .maptip.t3').addClass('animation-maptip');
		$(nowPage+' .js.js3').addClass('animation-js');
		$(nowPage+' .a-taps .c3').addClass('animation-scale');
	},900);
	setTimeout(function(){
		$(nowPage+' .maptip.t4').addClass('animation-maptip');
		$(nowPage+' .a-taps .c4').addClass('animation-scale');
	},1300);
	setTimeout(function(){
		$(nowPage+' .maptip.t5').addClass('animation-maptip');
		$(nowPage+' .a-taps .c5').addClass('animation-scale');
	},1500);
	setTimeout(function(){
		$(nowPage+' .maptip.t6').addClass('animation-maptip');
		$(nowPage+' .a-taps .c6').addClass('animation-scale');
	},1800);
	setTimeout(function(){
		$(nowPage+' .maptip.t7').addClass('animation-maptip');
		$(nowPage+' .a-taps .c7').addClass('animation-scale');
	},2000);*/
}

//页面打开三秒后开始加载全部大体积图片，加块显示速度。经实验。非3GWIFI环境会更卡，临时屏蔽
setTimeout(function(){
	var html='';
	 
	
		$(' .hidecontent').html(html);
},6000);
	
	
//定义AJAZX按钮
$('.notclick').tap(function () {
	$(this).removeClass('notclick');
	$(this).addClass('on');
	$(".clickpage .cp4").addClass('pt-page-scalesmall');
    getajax();
});
 

})();


//提交签到数据并返回排行
function getajax(){
		 $.getScript("http://table.chinanews.com/txtcount/count.php?id=9150315");

}